package com.pine.app.module.security.oauth.user.password;


import com.pine.app.module.security.core.common.enums.ErrorType;
import com.pine.app.module.security.oauth.exception.BadCredentialsException;
import org.apache.commons.lang3.StringUtils;

/**
 * @author xiaoyuan
 * @create 2020/3/7 11:06
 **/
public   abstract   class AbstractPasswordVerifiers implements PasswordVerifiers {
    @Override
    public boolean verifiers(String resource, String target) {
        if(StringUtils.isEmpty(resource)||StringUtils.isEmpty(target)){
            ErrorType.ILLEGAL_USERNAME_OR_PASSWORD.throwThis(BadCredentialsException::new);
        }
        boolean result = this.validatePassword(resource,target);
        return result;
    }

     protected abstract boolean  validatePassword(String resource, String target);
}
